﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="JsApiPayPage.aspx.cs" Inherits="wechat_JsApiPayPage" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <meta http-equiv="content-type" content="text/html;charset=utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <title>微信支付</title>
    <link href="styles/bootstrap.min.css" rel="stylesheet" />
    <link href="styles/weui.css" rel="stylesheet" type="text/css" />
    <script src="scripts/jquery-1.11.2.min.js" type="text/javascript"></script>
    <script src="Scripts/bootstrap.min.js" type="text/javascript"></script>
    <script src="scripts/jquery.query-2.1.7.js" type="text/javascript"></script>
</head>
<script type="text/javascript">
        $(function () {
        callpay();
        });
               //调用微信JS api 支付
               function jsApiCall()
               {
                   WeixinJSBridge.invoke(
                   'getBrandWCPayRequest',
                   <%=wxJsApiParam%>,//josn串
                    function (res)
                    {
                      // 判断前端返回,微信团队郑重提示：res.err_msg将在用户支付成功后返回    ok，但并不保证它绝对可靠。
                       if (res.err_msg == "get_brand_wcpay_request:ok") {
                                   window.location.href = 'index.html?at=list';
                       }
                     });
               }

               function callpay()
               {
                   	if (typeof('WeixinJSBridge') == "undefined"){
//                   if (typeof WeixinJSBridge == "undefined")
//                   {
                       if (document.addEventListener)
                       {
                           document.addEventListener('WeixinJSBridgeReady', jsApiCall, false);
                       }
                       else if (document.attachEvent)
                       {
                           document.attachEvent('WeixinJSBridgeReady', jsApiCall);
                           document.attachEvent('onWeixinJSBridgeReady', jsApiCall);
                       }
                   }
                   else
                   {
                       jsApiCall();
                   }
               }
 
</script>
<body>
    <form id="Form1" runat="server">
    <div class="container width90 pt20">
        <div class="page">
            <div class="bd">
                <div class="weui_msg">
                    <div class="weui_icon_area">
                    </div>
                    <div class="weui_text_area">
                        <p class="weui_msg_desc">
                            订单编号：<span runat="server" id="orderNo"></span></p>
                        <h2 class="weui_msg_title">
                            支付金额：￥<span runat="server" id="payCount"></span></h2>
                    </div>
                    <div class="weui_opr_area">
                        <p class="weui_btn_area">
                            <a href="javascript:;" class="weui_btn weui_btn_primary" onclick="callpay()">确认支付</a>
                            <a href="index.html?at=list" class="weui_btn weui_btn_default" id="btnBack">返回</a>
                        </p>
                    </div>
                </div>
            </div>
        </div>
    </div>
    </form>
</body>
</html>
